<?php 
include("../mysql_connect.php");
include("PHPMailer/class.phpmailer.php");
include("../error/upload.php");

$strSqlCommand = "SELECT Password
				  FROM user
				  WHERE Email = '".$_POST['Email']."'";
							
$result = mysql_query($strSqlCommand);
$rowUserInfo = @mysql_fetch_array($result);
if ($rowUserInfo=="")
{
	echo "The Email you entered is incorrect.";
	return;
}

$mail = new PHPMailer(); 				//New instance, with exceptions enabled		
$mail->IsSMTP();                        // tell the class to use SMTP
$mail->SMTPAuth   = true;               // enable SMTP authentication
			
$mail->SMTPSecure = "ssl";
$mail->Port       = 465;                // set the SMTP server port
$mail->Host       = "smtp.gmail.com";   // SMTP server
$mail->Username   = "info@bespoke-app.com";     // SMTP server username
$mail->Password   = "gobespoke";                // SMTP server password
		
$mail->From       = "info@bespoke-app.com";
$mail->FromName   = "Bespoke";
$to = $_POST['Email'];
$mail->AddAddress($to);  
			
$mail->Subject  = "Password Email From bespoke";
$mail->Body = "This is your Password!<p><b>".$rowUserInfo['Password']."</b></p>";
$mail->IsHTML(true);      
if(!$mail->Send()) {
	echo "Mailer Error: " . $mail->ErrorInfo;
	SaveError("ForgotPassword", NULL, date("Y-m-d H:i:s"), $mail->ErrorInfo);
}
else {
	echo "Message sent!";
}

?>
